package com.bluebench.bigul.domain.graphics.simple.polygon;

import java.util.List;

import com.bluebench.bigul.domain.graphics.Line;
import com.bluebench.bigul.domain.graphics.Point;
import com.itextpdf.text.pdf.PdfContentByte;

public abstract class Triangle extends Polygon{
	
	public static final int A=0;
	public static final int B=1;
	public static final int C=2;
		
	protected Triangle(PdfContentByte canvas) {
		super(canvas);
	}

	public List<Point> getVertices() {
		return vertices;
	}

	public void setVertices(List<Point> vertices) {
		this.vertices = vertices;
	}

	public Double getIncludedAngle(List<Float> sides, int vertex){
		float c = sides.get(0); 
		float a = sides.get(1); 
		float b = sides.get(2);
		Double cosAngle = null;   
		switch(vertex){
		
			case A:
				cosAngle = (Math.pow(c,2) + Math.pow(b,2) -Math.pow(a,2))/(2*b*c); 
				break;
			case B:
				cosAngle = (Math.pow(a,2) + Math.pow(c,2) -Math.pow(b,2))/(2*a*c); 
				break;
			case C:
				cosAngle = (Math.pow(a,2) + Math.pow(b,2) -Math.pow(c,2))/(2*a*b);
				break;
			default:
				//TODO : Throw Exception
		
		}
		
		if(cosAngle!=null){
			return Math.acos(cosAngle);
		}
		return null;
	}
	
}
